package cn.itsource.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Date;
import java.util.List;
import java.util.Map;
// 读取配置文件 @Configuration
// 1 方式1：@Value("${person.last-name}") 读少量配置
// 2 方式2：@ConfigurationProperties(prefix = "person") 把一堆配置文件读取为一个对象
// 3 方式3：@PropertySource("classpath:jdbc.properties") //指定从那个配置文件读取，只支持properties
@Data
@Configuration
@ConfigurationProperties(prefix = "person")
public class Person {

    //如果配置文件中有大写，按照规范要用-分隔
    //@Value("${person.last-name}")
    private String lastName;
    //@Value("${person.age}")
    private Integer age;
    @Value("${person.boss}")
    private Boolean bos;
    private Date birth;

    private Map<String, Object> maps;
    private List<Object> lists;
    private Dog dog;
}